package com.lili.setting.controller;

import com.lili.common.result.Result;
import com.lili.model.setting.Department;
import com.lili.model.setting.DepartmentRole;
import com.lili.setting.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/setting/dept")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    /**
     * 保存部门信息 一级二级
     *
     * @param department
     * @return
     */
    @PostMapping("/save")
    public Result saveDept(@RequestBody Department department) {

        departmentService.saveDept(department);

        return Result.ok();
    }

    /**
     * 保存部门权限数据
     * @param departmentRole
     * @return
     */
    @PostMapping("/saveRoleDept")
    public Result saveRoleDept(@RequestBody DepartmentRole departmentRole){
        departmentService.saveRoleDept(departmentRole);
        return Result.ok();
    }

    /**
     * 查询全部的部门信息
     * @return
     */
    @GetMapping("/list")
    public Result getDeptList(){
        List<Department> list = departmentService.getList();
        return Result.ok(list);
    }





}
